package twi.query;

import java.util.Iterator;
import java.util.Map;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import twi.OWLModel;

public class SparqlQuery extends Query {

	private String sparql;

	public SparqlQuery(String sparql, OWLModel model) {
		this(sparql, model, false);
	}
	public SparqlQuery(String sparql, OWLModel model, boolean replacePrefix){
		super(model);
		this.sparql = sparql;
		if (replacePrefix){
			Map prefmap = model.getNsPrefixMap();
			Iterator iter = prefmap.keySet().iterator();
			while(iter.hasNext()){
				String key = (String) iter.next();
				String val = (String) prefmap.get(key);
				this.sparql = this.sparql.replace(val, key+":");
			}
		}
		System.out.println(this.sparql);
		
	}

	@Override
	public String getSPARQLString() {
		return createPrefixDeclarations(model) + "\n" + sparql;
	}

	@Override
	public void decodeString(String filterString) {
		throw new NotImplementedException();
	}

	@Override
	public String encodeString() {
		throw new NotImplementedException();
	}

}
